<?php
function outGrade($grades) {
    $maxVal = max($grades);
    $minVal = min($grades);
    foreach ($grades as $name => $score) {
        if ($score == $maxVal && $maxReferee == '') {
            $maxReferee = $name;
        }
        if ($score == $minVal && $minReferee == '') {
            $minReferee = $name;
        }
    }
    echo "打出最低分的裁判为：{$minReferee}，打分为：{$minVal}\n";
    echo "打出最高分的裁判为：{$maxReferee}，打分为：{$maxVal}\n";

    $filtered = $grades;
    unset($filtered[$maxReferee]);
    unset($filtered[$minReferee]);
    $average = array_sum($filtered) / count($filtered);
    echo "最后得分为：" . number_format($average, 2) . "\n";
}
$grades = [
    '一号裁判' => 98.2,
    '二号裁判' => 97.5,
    '三号裁判' => 91,
    '四号裁判' => 89,
    '五号裁判' => 99,
    '六号裁判' => 98.5,
    '七号裁判' => 96.6,
    '八号裁判' => 93.4,
];
outGrade($grades);